<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp" %>

<head>
    <title>New Transactions</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <link rel="stylesheet" href="<c:url value="/css/styles.css"/>"/>
    <script src="<c:url value="/javascripts/common.js"/>" type="text/javascript"></script>

    <link rel="stylesheet"
          href="<c:url value="/javascripts/jscalendar/theme/calendar-system.css"/>"/>
    <script src="<c:url value="/javascripts/jscalendar/calendar-cfg.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/javascripts/calendar.js"/>" type="text/javascript"></script>
    <script
            src="<c:url value="/javascripts/jscalendar/lang/calendar-en.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/javascripts/jscalendar/calendar-setup.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/javascripts/jquery-1.4.4.js"/>" type="text/javascript"></script>

</head>

<body>
<div class="page">
    <%@include file="../top_menu.jsp" %>
    <table width=100%>
        <tr>
            <td>
                <%@include file="/WEB-INF/jsp/include/messages.jsp" %>
                <br/></td>
        </tr>
    </table>
    <div class="contentArea">

        <c:choose>
            <c:when test="${empty transactions.transactionDetails}">
                <tr>
                    <td colspan="12"><spring:message
                            code="sp.transactionform.label.atpresenttherearenotransactiontext"/>.<br/>
                        <spring:message code="sp.transactionform.label.ifyouwereexpectingsometransactiontext"/></td>
                </tr>
            </c:when>
            <c:otherwise>

                <table border=0 cellpadding=0 cellspacing=0>
                    <tr>
                        <td style="font-weight: bold;"><spring:message
                                code="sp.transactionform.label.approvepayment"/></td>
                    </tr>
                    <tr>
                        <td colspan="2"><h5>STEP 1 of 2</h5></td>
                    </tr>
                </table>
                <form:form id="main" commandName="transactions" method="post" action="step2.htm">
                    <c:set var="numberOfPayees" value="${fn:length(transactions.chosenPayeeMap)}"/>

                    <table border=0 cellpadding=4 cellspacing=1 width=100% bgcolor="#D7D7D7">
                        <tr>
                            <td colspan="6">&nbsp;</td>
                        </tr>
                        <tr bgcolor="#FAFAF7">
                            <td align="center" rowspan="3" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.ser"/></td>
                            <td align="center" rowspan="3" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.ssn"/></td>
                            <td align="center" rowspan="3" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.customername"/></td>
                            <td align="center" rowspan="3" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.amountreceived"/></td>
                            <td align="center" colspan="${numberOfPayees + 2}" style="font-weight: bold;">Miscellaneous
                                Payments
                            </td>
                            <td align="center" rowspan="3" style="font-weight: bold;">Customer Balance</td>
                            <td align="center" rowspan="3" style="font-weight: bold;">Select <a href="#"
                                                                                                onclick="return ch_select(true);">All</a>
                                /
                                <a href="#" onclick="return ch_select(false);">None</a></td>
                        </tr>

                        <tr bgcolor="#FAFAF7">
                            <td align="center" rowspan="2" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.svcfee"/></td>
                            <td align="center" rowspan="2" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.selffee"/></td>
                            <c:if test="${numberOfPayees > 0}">
                                <td align="center" colspan="${numberOfPayees}" style="font-weight: bold;">Payee's Name
                                </td>
                            </c:if>
                        </tr>

                        <tr bgcolor="#FAFAF7">
                                <%--Payee columns--%>
                            <c:forEach var="payee" items="${transactions.chosenPayeeMap}">
                                <td align="center"
                                    style="font-weight: bold;">${payee.value.firstName} ${payee.value.lastName}
                                </td>
                            </c:forEach>
                        </tr>

                        <c:forEach var="transaction" items="${transactions.transactionDetails}" varStatus="i">
                            <c:if test="${transaction.value.checked}">
                                <tr bgcolor="#FFFFFF">
                                    <td align="center">${transaction.key}
                                        <form:hidden path="transactionDetails[${transaction.key}].userId"/></td>

                                    <td align="left">${transaction.value.customerSSN}
                                        <form:hidden path="transactionDetails[${transaction.key}].customerSSN"/></td>

                                    <td align="left">${transaction.value.customerName}
                                        <form:hidden path="transactionDetails[${transaction.key}].customerName"/></td>

                                    <td align="right"><form:input path="transactionDetails[${transaction.key}].amount"
                                                                  disabled="true" cssClass="disabled"/>
                                        <form:hidden path="transactionDetails[${transaction.key}].amount"/></td>

                                    <td align="right"><form:input
                                            path="transactionDetails[${transaction.key}].serviceFee" disabled="true"
                                            cssClass="disabled"/>
                                        <form:hidden path="transactionDetails[${transaction.key}].serviceFee"/></td>

                                    <td align="right"><form:input path="transactionDetails[${transaction.key}].selfFee"
                                                                  disabled="true" cssClass="disabled"/>
                                        <form:hidden path="transactionDetails[${transaction.key}].selfFee"/></td>
                                    <!-- SELF fee -->

                                    <c:forEach var="payee" items="${transactions.chosenPayeeMap}" varStatus="p">
                                        <td align="right"><form:input
                                                path="transactionDetails[${transaction.key}].amounts[${payee.key}]"
                                                disabled="true" cssClass="disabled"/>
                                            <form:hidden
                                                    path="transactionDetails[${transaction.key}].amounts[${payee.key}]"/>
                                        </td>
                                        <!-- Payee fee -->
                                    </c:forEach>
                                    <td align="right"><form:input
                                            path="transactionDetails[${transaction.key}].customerBalance"
                                            disabled="true" cssClass="disabled"/>
                                        <form:hidden path="transactionDetails[${transaction.key}].customerBalance"/>
                                        <form:hidden path="transactionDetails[${transaction.key}].miscPayments"/></td>
                                    <td align="center"><form:checkbox
                                            path="transactionDetails[${transaction.key}].checked"/></td>
                                </tr>
                            </c:if>
                        </c:forEach>
                        <tr bgcolor="#FAF7F7">
                            <td colspan="18" style="font-weight: bold;"><spring:message
                                    code="sp.transactionform.label.messageoftheday"/></td>
                        </tr>
                        <tr bgcolor="#FAF7F7">
                            <td colspan="18" style="color: green; font-weight: bold;">NOTE: ALL THE UNCHECKED / NON
                                SELECTED TRANSACTIONS WILL BE AUTO RETURNED TO THE "NEW TRANSACTIONS" PAGE.
                            </td>
                        </tr>
                        <tr bgcolor="#FAF7F7">
                            <td colspan="18" style="color: green; font-weight: bold;">IF YOU WANT TO CHANGE PAYEES FOR
                                CERTAIN TRANSACTIONS THEN YOU CAN UNCHECK THOSE TRANSACTIONS AND CONTINUE TO PROCESS THE
                                REST. THE UN-CHECKED ROWS WILL BE AUTO MOVE BACK TO "NEW TRANSACTIONS" PAGE. AFTER YOU
                                ARE DONE PROCESSING THE SELECTED ROWS, YOU MAY LATER VISIT THE "NEW TRANSACTIONS" PAGE
                                TO MAKE YOUR CHANGES.
                            </td>
                        </tr>
                        <tr bgcolor="#FAF7F7">
                            <td colspan="18" style="color: green; font-weight: bold;">IF YOU WANT TO CHANGE PAYMENT
                                AMOUNTS THEN SIMPLY CLICK "Edit Payment Amounts". ALL THESE ROWS WILL SHOW UP IN THE
                                EDIT PAGE. SO DOES NOT MATTER WHETER USER SELECTED ANY ROW OR NOT. HENCE ALL THE ROWS
                                WILL SHOW UP FOR EDITING.....
                            </td>
                        </tr>
                        <tr bgcolor="#FAF7F7">
                            <td colspan="18" style="color: green; ">
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td colspan="18" align="left" style="padding-left:25px;" width="100%"><br>
                                <input type="submit" value="Edit Amounts" name="button_back"
                                       class='ui-button ui-state-default ui-corner-all'>
                                <input type="submit" value="Go To Step 2" name="button_approve"
                                       class='ui-button ui-state-default ui-corner-all'></td>
                        </tr>
                    </table>
                </form:form>
            </c:otherwise>
        </c:choose>
        <div id="error" class="errors"></div>

    </div>
</div>
<%@include file="/WEB-INF/jsp/include/footer.jsp" %>
</body>
</html>